Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(verifier): verify_bytes api GRO-304 #1784

Merged
merged 6 commits into from
Nov 12, 2024
Merged

Conversation

yuwen01
Copy link
Contributor

@yuwen01 yuwen01 commented Nov 12, 2024

Copy link

github-actions bot commented Nov 12, 2024

SP1 Performance Test Results

Branch: yuwen/verifier-bytes-api
Commit: 1308ecf
Author: yuwen01

program cycles execute (mHz) core (kHZ) compress (KHz) time success
fibonacci 11291 0.17 2.79 0.47 24s
ssz-withdrawals 2757356 17.46 129.60 35.70 1m17s
tendermint 12593597 6.68 268.40 99.81 2m8s

@yuwen01 yuwen01 changed the title feat(verifier): verify_bytes api feat(verifier): verify_bytes api GRO-304 Nov 12, 2024
### Advanced: `verify_bytes`

`sp1-verifier` also exposes [`Groth16Verifier::verify_bytes`](https://docs.rs/sp1-verifier/latest/sp1_verifier/struct.Groth16Verifier.html#method.verify_bytes) and [`PlonkVerifier::verify_bytes`](https://docs.rs/sp1-verifier/latest/sp1_verifier/struct.PlonkVerifier.html#method.verify_bytes),
which verifies any Groth16 or Plonk proof from gnark. This is especially useful for verifying custom Groth16 and Plonk proofs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix: Capitalize Gnark, and add a link to https://docs.gnark.consensys.io/, or the repo.

zkVM, instead of ZKVM.

}
```

Public values are serialized as big-endian `Fr` values. The default gnark serialization will work
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalize Gnark

///
/// This method expects the raw proof bytes without the 4-byte vkey hash prefix that
/// [`verify`] checks. If you have a complete proof with the prefix, use [`verify`] instead.
pub fn verify_bytes(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better name is verify_gnark_proof. verify_bytes isn't that specific. We should also add documentation to the function above to say that it's for SP1 proofs.

///
/// This method expects the raw proof bytes without the 4-byte vkey hash prefix that
/// [`verify`] checks. If you have a complete proof with the prefix, use [`verify`] instead.
pub fn verify_gnark_proof(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add #[must_use]

///
/// A [`Result`] containing unit `()` if the proof is valid,
/// or a [`PlonkError`] if verification fails.
pub fn verify_gnark_proof(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add #[must_use]

@@ -44,7 +44,7 @@ pub(crate) struct PlonkVerifyingKey {
/// # Returns
///
/// * `Result<bool, PlonkError>` - Returns true if the proof is valid, or an error if verification fails
pub(crate) fn verify_plonk_raw(
pub(crate) fn verify_plonk_algebraic(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add #[must_use] so people don't forget to unwrap

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must_use is already on by default for Result. doing something like this gives me a warning

crate::PlonkVerifier::verify(...);

@yuwen01 yuwen01 merged commit af1c35d into dev Nov 12, 2024
14 of 16 checks passed
@yuwen01 yuwen01 deleted the yuwen/verifier-bytes-api branch November 12, 2024 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants